package com.gupao.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Meipo implements InvocationHandler {

    private Person person;

    //获取被代理人的资料
    public Object getInstance( Person target)throws Exception{
        this.person = target;
        Class aClass = target.getClass();
        return Proxy.newProxyInstance(aClass.getClassLoader(),aClass.getInterfaces(),this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("你的性别是:" + this.person.getSex() + "你的姓名是： "+ this.person.getName());

        System.out.println("开始进行海选。。。。" );
        System.out.println("---------------------------" );

        this.person.findLove();
        System.out.println("---------------------------" );

        System.out.println("开始办事");


        return null;
    }
}
